<template>
  <!-- 大宗贸易商城 -->
  <div class="trade-wrap">
    <div class="header">
      <p class="title">大宗贸易商城</p>
    </div>
    <div class="display">
      <div class="item">
        <span class="icon icon1"></span>
        <p class="val">
          <count-to
            :startVal="0"
            :endVal="totalAmount"
            :duration="1000"
            :decimals="2"
            class="inline"
          ></count-to>
        </p>
        <p class="key">累计交易额(元)</p>
      </div>
      <div class="item">
        <span class="icon icon1"></span>
        <p class="val">
          <count-to
            :startVal="0"
            :endVal="totalCount"
            :duration="1000"
            class="inline"
          ></count-to>
        </p>
        <p class="key">累计交易笔数(笔)</p>
      </div>
      <div class="item">
        <span class="icon icon2"></span>
        <p class="val">
          <count-to
            :startVal="0"
            :endVal="productCount"
            :duration="1000"
            class="inline"
          ></count-to>
        </p>
        <p class="key">上架商品数(个)</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import CountTo from "@/components/vueCountTo/vue-countTo.vue";
import { ajax } from "@/store/service";

const totalAmount = ref(0);
const totalCount = ref(0);
const productCount = ref(0);

const getTradingMall = async () => {
  const [res] = await ajax.tradingMallAll();
  totalAmount.value = res.totalAmount;
  totalCount.value = res.totalCount;
  productCount.value = res.productCount;
};

onMounted(() => {
  getTradingMall();
});
</script>

<style scoped lang='scss'>
.trade-wrap {
  width: 584px;
  height: 293px;
  .header {
    height: 65px;
    background: url("@/assets/longscreen2/大宗贸易商城标题.svg");
    box-sizing: border-box;
    padding-top: 30px;
    padding-left: 37px;
    margin-bottom: 40px;
    .title {
      font-size: 22px;
      font-family: JLinXin;
      font-weight: 600;
      line-height: 22px;
      background: #fffde8 linear-gradient(180deg, #e8feff 40%, #00a9ff 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      font-weight: bold;
    }
  }
  .display {
    height: 191px;
    padding: 0 10px;
    display: flex;
    justify-content: space-between;
    // border: #00a9ff 1px solid;

    .item {
      // border: #00a9ff 1px solid;
      width: 178px;
      height: 191px;
      .icon {
        display: block;
        width: 120px;
        height: 120px;
        margin: 0 auto;
        margin-bottom: 10px;
      }
      .icon1 {
        background: url("@/assets/longscreen2/icon_累计交易笔数.png");
      }
      .icon2 {
        background: url("@/assets/longscreen2/icon_上架商品数.png");
      }
      .val {
        font-size: 26px;
        font-family: D-DIN-PRO-Heavy, D-DIN-PRO;
        font-weight: 800;
        color: #ffffff;
        line-height: 32px;
        letter-spacing: 1px;
        text-align: center;
        margin-bottom: 6px;
        .inline {
          display: inline;
        }

        .unit {
          font-size: 16px;
          font-family: SourceHanSansCN-Medium, SourceHanSansCN;
          font-weight: 500;
          color: #ffffff;
          line-height: 27px;
          opacity: 0.36;
        }
      }
      .key {
        font-size: 18px;
        font-family: SourceHanSansCN-Medium, SourceHanSansCN;
        font-weight: 500;
        color: #ffffff;
        line-height: 27px;
        text-align: center;
        opacity: 0.7;
      }
    }
  }
}
</style>